package com.kh.pajx.sop.dao.impl;



import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.kh.pajx.sop.base.BaseDaoImpl;
import com.kh.pajx.sop.dao.IHsEquipmentInfoDao;
import com.kh.pajx.sop.domain.HsEquipmentInfo;
import com.kh.pajx.sop.domain.SysInsideUser;

/**
 * 设备信息dao层实现类
 * @author 熊刘伟
 * @createDate 2014年6月24日 上午11:24:26 
 * @return
 * @param
 */
@Repository
public class HsEquipmentInfoDaoImpl extends BaseDaoImpl<HsEquipmentInfo> implements
		IHsEquipmentInfoDao {

	@Override
	public void updateByEquNo(Long[] equNos) {
		String hql = "update HsEquipmentInfo equ set equ.equStausFlag = 0 where equ.equNo in (:equNos)";
		getSession().createQuery(hql).setParameterList("equNos",equNos).executeUpdate();
	}

	@Override
	public List<HsEquipmentInfo> findByCondition() {
		Criteria cri = getSession().createCriteria(HsEquipmentInfo.class);
		cri.add(Restrictions.eq("equStausFlag","1"));
		return cri.list();
	}

	@Override
	public List<SysInsideUser> findInUser(String[] isuIds) {
		Criteria cri = getSession().createCriteria(SysInsideUser.class);
		cri.add(Restrictions.in("isuId",isuIds));
		return cri.list();
	}

	@Override
	public List<HsEquipmentInfo> getAllEquByEquNo(Long[] equNos) {
		// TODO Auto-generated method stub
		return getSession().createCriteria(HsEquipmentInfo.class,"heq").add(Restrictions.in("heq.equNo",equNos)).list();
	}

	@Override
	public HsEquipmentInfo getEquByEquNo(Long equNo) {
	    return (HsEquipmentInfo) getSession().createCriteria(HsEquipmentInfo.class,"equ").add(Restrictions.eq("equ.equNo", equNo)).add(Restrictions.eq("equ.equStausFlag","1")).uniqueResult();
	}
}
